﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;

public class SkillList : MonoBehaviour
{
    private static List<Skill> skillList = new List<Skill>();
    void Start()
    {
        GetSkillList();
    }

    private void GetSkillList()
    {
        TextAsset skillJson = Resources.Load<TextAsset>("SkillList");

        JsonData jsonData = JsonMapper.ToObject(skillJson.text);

        for (int i = 0; i < jsonData.Count; i++)
        {
            int id = (int)jsonData[i]["id"];
            string name = (string)jsonData[i]["name"];
            SkillType skillType = (SkillType)System.Enum.Parse(typeof(SkillType), jsonData[i]["skillType"].ToString());
            string skillSprite = (string)jsonData[i]["skillSprite"];
            string des = (string)jsonData[i]["des"];

            Skill skill = new Skill(id, name, skillType, skillSprite, des);

            skillList.Add(skill);
        }
    }
    public static Skill GetSkillById(int id)
    {
        return skillList[id];
    }
}
